<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-bind="">
<head>
    <meta charset="UTF-8">
    <title>权限管理</title>
    <link href="../../resources/css/common/bootstrap3.min.css" rel="stylesheet" type="text/css" />
    <link href="../../resources/css/common/page.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../resources/css/common/component.css" />
</head>
<!--<link rel="import" href="/html/common/common_list.html" >-->
<div class="container body-content">
    <div id="demo">
        <div class="form-inline" style="margin:2% 0">
            <div class="form-group">
                <button type="button" class="btn btn-primary btn-sm" @click="add_permission_dialg(0,'','','')">
                    添加
                </button>
            </div>
        </div>


        <div class="form-group">
            <table class="table table-bordered table-responsive table-striped">
                <thead>
                <tr>
                    <th v-for="(value, key) in gridColumns">
                        {{ key | capitalize }}
                    </th>
                    <th>操作</th>
                </tr>
                </thead>
                <tr v-for="entry in gridData">
                    <td v-for="(value, key) in gridColumns">
                        <div v-html="showHtml(entry[key],value)"></div>
                    </td>
                    <td>

                        <button type="button" class="btn btn-primary btn-sm" @click="add_permission_dialg(entry['id'],entry['permissionName'],entry['tagCode'],entry['remarkNote'])">
                            修改信息
                        </button>
                        <button type="button" class="btn btn-danger btn-sm" @click="del_permission(entry['id'])">
                            删除
                        </button>
                    </td>
                </tr>
            </table>
        </div>



        <div  class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">修改信息</h4>
                    </div>
                    <div class="modal-body">
                        <input type="hidden" id="permissionId"/>
                            <form>
                                <table align="center" width="300" height="200" border=0>
                                    <tr>
                                        <td>
                                            <label>权限名称:</label>
                                        </td>
                                        <td>
                                            <input v-model="permissionName" type="text" placeholder="权限名称">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <label>权限码:</label>
                                        </td>
                                        <td>
                                            <input v-model="tagCode"  type="text" placeholder="权限码">
                                        </td>
                                    </tr>
                                </table>
                            </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button"  class="btn btn-default" onclick="savePermission()">提交</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <hr />
    <footer>
    </footer>
</div>



<div id="app">
    <page></page>
</div>


</body>
<script type="text/javascript" src="../../resources/js/common/jquery-2.1.1.min.js"></script>
<script src="../../resources/js/common/bootstrap3.min.js" type="text/javascript"></script>
<script src="../../resources/js/common/vue.min.js"></script>
<script src="../../resources/js/common/load_list.js"></script>
<script src="../../resources/js/common/common.js"></script>
<script>
    //默认数据
    var runUrl='/operator/query_permission';
    var param= {};
    var data={permissionName:'',
    tagCode:'',
    permissionId:0};
    //列表th信息
    data['th']={'id':'权限ID', 'permissionName':'权限名称','tagCode':'权限码','updateTime':'修改时间'};
    //列表字段信息以及类型  类型 video vioce img a no 五种
    data['gridColumns'] = {'id':'no', 'permissionName':'no','tagCode':'no','updateTime':'no'};

</script>

<script>

    function del_permission(id){
        jQuery.get("/operator/del_permisssion", {id: id}, function (data) {
            if(data.retCode == 1){
                alert("操作成功！！！");
                window.location.href="/html/operator/permission.html";
            }else{
                alert("操作失败，请重试！！！");
            }
        });
    }
    function add_permission_dialg( permissionId, permissionName,tagCode){
        demo.permissionId=permissionId;
        demo.permissionName=permissionName;
        demo.tagCode=tagCode;
        $('#myModal').modal({
            keyboard: true
        });
    }
    function savePermission()
    {
        if(demo.permissionName=="")
        {
            alert("权限名称不能为空");
            return ;
        }
        if(demo.tagCode=="")
        {
            alert("权限码不能为空");
            return ;
        }
        var param={};
        param['id']=demo.permissionId;
        param['tagCode']=demo.tagCode;
        param['permissionName']=demo.permissionName;
        var data= executeAjaxByPost('/operator/add_permission',param);
        if(data.retCode==1)
        {
            alert("保存成功");
            window.location.href = "/html/operator/permission.html";
        }
        else
        {
            alert("保存失败"+data.retMsg);
            return;
        }
        return ;

    }


</script>
</html>

